package com.jx.db137.controller;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.jx.db137.common.R;
import com.jx.db137.entity.Userrole;
import com.jx.db137.service.UserroleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author jx
 * @version 1.0
 * @Description
 * @date 2024/12/24 11:51
 */
@CrossOrigin(origins = "*")
@RestController
public class UserroleController {
    @Autowired
    private UserroleService userroleService;

    @PostMapping("/deleteByUseridAndRoleid")
    public R deleteByUseridAndRoleid(@RequestBody Userrole userrole){
        UpdateWrapper<Userrole> userroleUpdateWrapper = new UpdateWrapper<>();
        userroleUpdateWrapper.setEntity(userrole);
        this.userroleService.remove(userroleUpdateWrapper);
        System.out.println(userrole.getRoleid()+"-------" + userrole.getUserid());
        return new R();
    }
    @PostMapping("/addUserrole")
    public R addUserrole(@RequestBody Userrole userrole){
        this.userroleService.save(userrole);
        return new R();
    }
}
